import 'package:flutter/material.dart';
import "package:get/get.dart";

import '../../apis/base.dart';
import '../../components/status/toast.dart';
import '../../router/router.dart';
import 'Dialog.dart';

class ExitDialog {
  /// 退出对话框
  static exit(BuildContext context) {
    Dialogs.confirmDialog(
      context,
      title: "提示",
      content: "退出后需要重新登录，是否继续?",
      cancelTxt: "取消",
      cancel: () => null,
      confirmTxt: "确定",
      confirm: () async {
        Toast.loading(title: "正在退出");

        try {
          // 执行退出
          await Base.logout();

          // 跳转界面
          Get.offAllNamed(AppRoutes.Login);
        } catch (e) {}

        // 关闭动画
        Toast.closeToast();
      },
    );
  }
}
